//安全帽模块
const { ethers, upgrades } = require('hardhat')
// 代理合约地址
const proxyAddress = '0x8A791620dd6260079BF849Dc5567aDC3F2FdC318'

async function main() {
  console.log(proxyAddress, ' original proxy address')
  const UUPSV2 = await ethers.getContractFactory('UUPSV2')
  console.log('upgrade to UUPSV2...')
  const myUUPSV2 = await upgrades.upgradeProxy(proxyAddress, UUPSV2)

  const myUUPSV2Address = myUUPSV2.target
  console.log(myUUPSV2Address, ' UUPSV2 address(should be the same)')

  console.log(
    await upgrades.erc1967.getImplementationAddress(myUUPSV2Address),
    ' getImplementationAddress',
  )
  console.log(
    await upgrades.erc1967.getAdminAddress(myUUPSV2Address),
    ' getAdminAddress',
  )
}

main()
  .then(() => process.exit(0))
  .catch((error) => {
    console.error(error)
    process.exit(1)
  })
